<template>
    <div class="flexbox flexcolumn height_100">
        <div class="flex over_box">
            <div class="com_box">
                <StepBox :dataForm="dataForm" />
                <UserData :dataForm="dataForm" @sessionSave="sessionSave" :adverList="adverList" />
            </div>
            <UserCreat :dataForm="dataForm" @sessionSave="sessionSave" :adverList="adverList" />
        </div>
        <div class="tk_footer com_box">
            <!-- <el-button plain class="el-button-width plain_red" size="small" @click="cancelCreation">取消创建</el-button>
            <el-button plain class="el-button-width" size="small" @click="preStep">上一步</el-button> -->
            <el-button type="primary" class="el-button-width" size="small" @click="nextTwo">下一步</el-button>
        </div>
    </div>
</template>

<script>
import { mixins } from "@/assets/js/tkmixins.js";
import StepBox from "./model/StepBox";
import UserData from "./model/UserData";
import UserCreat from "./model/UserCreat";
export default {
    components: {
        StepBox,
        UserData,
        UserCreat,
    },
    mixins: [mixins],
    props: ["dataForm"],
    name: "",
    data() {
        return {
            adverList: [],
        };
    },
    created() {
        this.getAdverList();
    },
    computed: {},
    methods: {
        //获取广告账户列表
        async getAdverList() {
            const { data: res } = await this.$http.post(
                this.$tiktokUrl + "launch/TiktokInfo/advertiserList"
            );
            if (res.code !== 200) {
                this.$message.error(res.msg);
                return;
            } else {
                this.adverList = res.data.list;
            }
        },

        // 提交
        nextTwo() {
            if (!this.dataForm.base[0].advertiser_id) {
                this.$message.error("请选择资产账户！");
                return;
            } else if (!this.dataForm.base[0].store_id) {
                this.$message.error("请选择资产商店！");
                return;
            } else if (!this.dataForm.base[0].identity_id) {
                this.$message.error("请选择资产身份！");
                return;
            }else if(this.dataForm.advertiser_ids.length==0){
                this.$message.error("请选择广告创建账户！");
                return;
            } else {
                this.dataForm.is_change = true;
                this.dataForm.step = 2;
                this.sessionSave();
            }
        },

        // 上一步
        preStep() {
            this.dataForm.step = 1;
            this.sessionSave();
        },

        sessionSave() {
            window.sessionStorage.setItem(
                "tkForm",
                JSON.stringify(this.dataForm)
            );
        },
    },
};
</script>


<style scoped>
</style>

<style>
</style>
